<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
    <Nullable>enable</Nullable>
    <TestRunRequiresLiveRefPack>true</TestRunRequiresLiveRefPack>
    <!--
      RS1036: A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'
      The only analyzer defined here is a mock analyzer meant to act similarly to our source generator. It is not shipping and is only used in unit tests.
      We don't want to enable the rest of the "good behaving analyzer" API rules on our tests as it is test code and not shipping code.
      -->
    <NoWarn>$(NoWarn);RS1036</NoWarn>
    <StringResourcesPath>../../gen/Common/Resources/Strings.resx</StringResourcesPath>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="$(CommonTestPath)SourceGenerators\LiveReferencePack.cs"
            Link="Common\SourceGenerators\LiveReferencePack.cs" />
    <Compile Include="$(CommonTestPath)SourceGenerators\GlobalOptionsOnlyProvider.cs"
            Link="Common\SourceGenerators\GlobalOptionsOnlyProvider.cs" />
    <Compile Include="..\Common\TestUtils.cs"
            Link="Common\TestUtils.cs" />
    <Compile Include="..\Common\TargetFrameworkOptions.cs"
            Link="Common\TargetFrameworkOptions.cs" />
    <Compile Include="..\Common\CustomCollectionMarshallingCodeSnippets.cs"
            Link="Common\CustomCollectionMarshallingCodeSnippets.cs" />
    <Compile Include="..\Common\CustomStructMarshallingCodeSnippets.cs"
            Link="Common\CustomStructMarshallingCodeSnippets.cs" />
    <Compile Include="..\Common\ICustomMarshallingSignatureTestProvider.cs"
            Link="ICustomMarshallingSignatureTestProvider.cs" />
    <Compile Include="..\Common\Verifiers\CSharpAnalyzerVerifier.cs"
            Link="Verifiers\CSharpAnalyzerVerifier.cs"/>
    <Compile Include="..\Common\Verifiers\CSharpCodeFixVerifier.cs"
            Link="Verifiers\CSharpCodeFixVerifier.cs"/>
    <Compile Include="..\Common\Verifiers\CSharpSourceGeneratorVerifier.cs"
            Link="Verifiers\CSharpSourceGeneratorVerifier.cs"/>
    <Compile Include="..\Common\Verifiers\CSharpVerifierHelper.cs"
            Link="Verifiers\CSharpVerifierHelper.cs"/>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisVersion)" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="$(CompilerPlatformTestingVersion)" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="$(CompilerPlatformTestingVersion)" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="$(CompilerPlatformTestingVersion)" />

    <!-- Upgrade transitive references of Microsoft.CodeAnalysis.Analyzer.Testing which bring in NS 1.x deps -->
    <PackageReference Include="DiffPlex" Version="$(CompilerPlatformTestingDiffPlexVersion)" />
    <PackageReference Include="Microsoft.VisualBasic" Version="$(CompilerPlatformTestingMicrosoftVisualBasicVersion)" />
    <PackageReference Include="Microsoft.VisualStudio.Composition" Version="$(CompilerPlatformTestingMicrosoftVisualStudioCompositionVersion)" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Ancillary.Interop\Ancillary.Interop.csproj" />
    <ProjectReference Include="..\..\gen\LibraryImportGenerator\LibraryImportGenerator.csproj" />
  </ItemGroup>

  <ItemGroup>
    <None Include="$(RepoRoot)/NuGet.config" Link="NuGet.config" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

  <!-- Reference the actual NetAnalyzers project to ensure we're testing our diagnostic suppressors against the actual analyzers they'll run with, not fake shims we have to maintain -->
  <ItemGroup Condition="'$(RunAnalyzers)' != 'false'">
    <PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" GeneratePathProperty="true" />
  </ItemGroup>
  <ItemGroup Condition="'$(RunAnalyzers)' == 'false'">
    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" ExcludeAssets="all" GeneratePathProperty="true" />
  </ItemGroup>

  <Target Name="AddNetAnalyzersAssemblyAsReference" BeforeTargets="ResolveAssemblyReferences" DependsOnTargets="ResolveProjectReferences">
    <ItemGroup>
      <Reference Include="$(PkgMicrosoft_CodeAnalysis_NetAnalyzers)/analyzers/dotnet/cs/Microsoft.CodeAnalysis.NetAnalyzers.dll" />
    </ItemGroup>
  </Target>
</Project>
